<script setup lang="ts">
	defineProps({
		// 标题
		title: {
			type: String,
			required: true
		},
		// 是否显示回退按钮
		enableBack: {
			type: Boolean,
			default: true,
		},
		enableRight: {
			type: Boolean,
			default: false,
		}
	})

	import { useI18n } from 'vue-i18n'
	const { t } = useI18n()
	import { comNavBarStyle } from '@/utils/system'
</script>
<template>
	<view class="nav-bar-container" :style="comNavBarStyle()">
		<view class="left-part">
			<!-- #ifndef MP-TOUTIAO -->
			<uni-icons type="left" class="left-icon" @click="uni.navigateBack()"></uni-icons>
			<!-- #endif -->
		</view>
		<view class="nav-bar-title">
			{{t(title)}}
		</view>
		<view class="right-part">
			<uni-icons type="left" color="transparent" v-if="!enableRight"></uni-icons>
			<slot name="right" v-else></slot>
		</view>
	</view>
</template>
<style scoped lang="scss">
	.nav-bar-container {
		width: 100%;
		padding: 30rpx 20rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		
		.left-part {
			width: 30%;
			.left-icon {
				padding: 10rpx;
			}
		}

		.right-part {
			width: 30%;
			display: flex;
			flex-direction: row;
			justify-content: flex-end;
		}

		.nav-bar-title {
			font-size: 25rpx;
		}
	}
</style>